# !/usr/bin/env python
# -*- coding: utf-8 -*-

# 选择排序
# 基本思想：选择当前元素和后面所有元素比较
# 时间复杂度:最好O(n^2),最坏O(n^2),平均O(n^2)
# 空间复杂度:最好0(已经排好序),最坏O(n)(逆序),平均O(1)
# 稳定性:不稳定
from sort.arr_util import random_scale_arr


def select_sort(num_arr):
    for i in range(0, len(num_arr) - 1):
        for j in range(i + 1, len(num_arr)):
            if num_arr[i] > num_arr[j]:
                tmp = num_arr[i]
                num_arr[i] = num_arr[j]
                num_arr[j] = tmp


if __name__ == '__main__':
    arr = [1, 2, 5, 7, 6, 5, 4]
    select_sort(arr)
    print(arr)
    arr2 = random_scale_arr(20, 500)
    select_sort(arr2)
    print(arr2)
